﻿using System;
using System.Collections.Generic;
using System.Linq;
using Infrastucture;

namespace TimeSplicerModule.DomainModels
{
    public class ApplicationRolePermissionModel : DomainObject
    {
        private Guid _applicationRolePermissionGuid;
        private Guid _applicationRoleGuid;
        private Guid _applicationItemGuid;
        private Guid _applicationPermissionGuid;
        private ApplicationRoleModel _role;
        private ApplicationItemModel _item;
        private ApplicationPermissionModel _permission;
        private List<ApplicationPermissionModel> _applicationPermissions;


        public Guid ApplicationRolePermissionGuid
        {
            get { return  _applicationRolePermissionGuid; }
            set { SetProperty(ref _applicationRolePermissionGuid, value); }
        }
        public Guid ApplicationRoleGuid
        {
            get { return _applicationRoleGuid; }
            set { SetProperty(ref _applicationRoleGuid, value); }
        }
        public Guid ApplicationItemGuid
        {
            get { return _applicationItemGuid; }
            set { SetProperty(ref _applicationItemGuid, value); }
        }
        public Guid ApplicationPermissionGuid
        {
            get { return _applicationPermissionGuid; }
            set 
            { 
                SetProperty(ref _applicationPermissionGuid, value);

                if (this.ApplicationPermissions != null)
                    this.Permission = this.ApplicationPermissions.FirstOrDefault(x => x.ApplicationPermissionGuid == this.ApplicationPermissionGuid);
            }
        }
        public ApplicationRoleModel Role
        {
            get { return _role; }
            set { SetProperty(ref _role, value); }
        }
        public ApplicationItemModel Item
        {
            get { return _item; }
            set { SetProperty(ref _item, value); }
        }
        public ApplicationPermissionModel Permission
        {
            get { return _permission; }
            set { SetProperty(ref _permission, value); }
        }
        public List<ApplicationPermissionModel> ApplicationPermissions
        {
            get { return _applicationPermissions; }
            set { SetProperty(ref _applicationPermissions, value); }
        }
    }
}
